#pragma once
#include "CourbeBezier.h"
#include <vector>
using namespace std;
class SurfaceBezier
{
private:
	Tableaux<CourbeBezier> _carreau;
	Tableaux<FacesP> _solide;
	vector<vector<Points3D>> _surface;
	
	
public:
	SurfaceBezier();
	SurfaceBezier(int nBPtCtrl,vector<vector<double>> &);
	SurfaceBezier(int nBPtCtrl);
	SurfaceBezier(SurfaceBezier &s);
	SurfaceBezier(Tableaux<CourbeBezier> surface);
	virtual ~SurfaceBezier();

	//Surcharge operateur
	CourbeBezier & operator [](int i);
	//
	int getDimension()const;
public:
	//Methodes
	void ajoutCourbe(const CourbeBezier & courbe, int pos);
	Points3D evaluer(double u,double v);
	Points3D & getPoint(int i, int j);
	Points3D & getPoint(int i);
	Tableaux<FacesP> & getSolide();
	void genererSurface(int largeur,int longeur);
	void triangulerSurface(AttributsFaces *af);
	void decoupage(SolidesP &,Tableaux<FacesP> &entre,Tableaux<FacesP> &sortie);
	static void intersectionBas(SolidesP& boite , Tableaux<FacesP> & faces,Tableaux<FacesP> & sortie,Points3D & origine, double taille);
private:
	void creerFace(int l, int h,AttributsFaces *af);
	static void decouperFaceCas1(FacesP & face,SolidesP &solide,Tableaux<FacesP> &sortie,int sommet);
	static void decouperFaceCas2(FacesP & face,SolidesP &solide,Tableaux<FacesP> &sortie,int *sommet);
	static void pointIntersection(Tableaux<FacesP>& faces,FacesP &face,Tableaux<SommetsP> &sortie);
	static void pointIntersection2(Tableaux<FacesP>& faces,FacesP &face,Tableaux<SommetsP> &sortie); 
	static void pointIntersection3(Tableaux<FacesP>& faces,FacesP &face,Tableaux<SommetsP> &sortie);
	static void relier(AttributsFaces & coul,Tableaux<SommetsP>& sommets,SommetsP & s1,SommetsP & s2,FacesP & sortie);
	static void sortX(Tableaux<SommetsP> & tab);
	static void sortY(Tableaux<SommetsP> & tab);
};
